package com.ld.oauth2.config.plus;


import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

import java.util.Date;

@Component
public class PropertyFillHandler implements MetaObjectHandler {
    @Override
    public void insertFill(MetaObject metaObject) {
        long currentTimeMillis = System.currentTimeMillis();
        Integer userId = 1;
        this.strictInsertFill(metaObject, "createrUserId", Integer.class, userId);
        this.strictInsertFill(metaObject, "createTime", Date.class, new Date());
        this.strictInsertFill(metaObject, "updateUserId", Integer.class, userId);
        this.strictInsertFill(metaObject, "updateTime", Date.class, new Date());
    }

    @Override
    public void updateFill(MetaObject metaObject) {
        long currentTimeMillis = System.currentTimeMillis();
        Integer userId = 1;
        this.strictUpdateFill(metaObject, "updateUserId", Integer.class, userId);
        this.strictUpdateFill(metaObject, "updateTime", Date.class, new Date());
    }
}
